﻿/**
 * @author sminutoli
 * version 1.0
 * 
 */
import com.dinmax.flash.draw.cabeza.*
class ControlCabeza
extends MovieClip {
	
	private var listeners:Array;
	private var value:Object;
	
	public function ControlCabeza() {
		this.listeners = new Array();
	};
	
	public function onLoad():Void {
		var parent:ControlCabeza = ControlCabeza(this._parent);
		if(parent) parent.initChild(this);
		return;
	};
	
	public function initChild(child:MovieClip):Void {
		return;
	};
	
	public function addListener(listener:ControlListener):Void{
		//trace("ControlCabeza.as addListener= "+listener);
		this.removeListener(listener);
		this.listeners.push(listener);
		return;
	};
	public function getListeners():Array {
		return this.listeners;
	};
	public function removeListener(listener:ControlListener):Void {
		for (var i : Number = 0; i < listeners.length; i++) {
			if(listeners[i] == listener){
				//trace("ControlCabeza.as | removeListener() | listener founded");
				listeners.splice(i, 1);
			};
		}
		return;
	};
	public function removeListeners():Void {
		this.listeners=new Array();
		return;
	};
	
	public function getValue():Object {
		return value;
	}

	public function setValue(value:Object):Void {
		this.value = value;
		return;
	};
		
	private function selectEvent():Void{
		for (var i : Number = 0; i < listeners.length; i++) {
			//trace("selectEvent= "+listeners[i]);
			SelectedListener(listeners[i]).selected(this);
		}
	};
	private function changeEvent(type:String):Void {
		for (var i:Number = 0; i < listeners.length; i++){
			ChangedListener(listeners[i]).changed(this, type);
		};
	};
}